-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX Supplier orders : delete dispatched lines on supplier order deletion #25292
Conversation
When product were shipped, and order is canceled after, the product are still shipped.
|
@eldy Text is added to en_US trans only |
htdocs/fourn/commande/card.php
Outdated
$dispatchedLines = $object->getDispachedLines(); | ||
if (!empty($dispatchedLines)) { | ||
foreach ($dispatchedLines as $dispatchedLine) { | ||
$db->begin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The begin end transaction must not be inside the loop. We must have 1 transaction for all the event so result in database will be everything done or nothing.
Commit must be after the delete if order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified code to locate correctly begin, rollback and commit instructions for db.
I noticed that $commande->delete also have a begin, rollback and commit logic on $this->db in the commande.class.php file.
If two transactions have begun in parallel, I prefered to finish all the logic on $db in the card.php code.
FIX|Fix #[Supplier orders : delete dispatched lines on supplier order deletion]
If stock increase is set up to dispatch to warehouse manually, the order deletion may cause stock issues.
You can valid an order, dispatch some lines (increasing your stock) and delete the order.
The lines are dispatched, the stock moves are written and you cannot access to the dispatch lines because the order has been removed from the database.
A warning has been added on deletion modal if there are existing dispatched lines.
If confirmed, for each dispatched line, we apply the same method used by clicking on the trash icon on a dispatch line.
The label for the stock move generated will be trans('SupplierOrderDeletion') By default : Supplier order %s Deletion